import {
    cardWidth,
    cardHeight
} from './varible.js'
//添加底部纸牌
function addBottomCard(info, array) {
    let lastIndex = array.length - 1;
    let divEl = addCard(info);

    // if (info.level == 0) {
    //     divEl.style.backgroundPosition = (info.card.number - 1) * -80 + "px 0px";
    // } else {
    //     divEl.style.backgroundPosition = "0px 720px";
    // }

    //后续需根据花色和类型来选择雪碧图中的图片
    // divEl.style.left = array[info.index][0] + 'px';
    // divEl.style.top = array[info.index][1] + 'px';
    divEl.style.zIndex = info.card.index;
    return divEl;
}
//添加牌桌区纸牌
function addTableCard(info, array, levelSize) {
    let divEl = addCard(info);
    divEl.className = "pic";
    if (info.level == 0) {
        divEl.style.backgroundPosition = (info.card.number - 1) * -1 * cardWidth + "px 0px";
    } else {
        // divEl.style.backgroundPosition = "0px 720px";
        divEl.style.backgroundPosition = "0px " + cardHeight * 6 + "px ";
    }

    //后续需根据花色和类型来选择雪碧图中的图片
    divEl.style.left = array[info.index][0] + 'px';
    divEl.style.top = array[info.index][1] + 'px';
    divEl.style.zIndex = levelSize + 1 - info.level;
    return divEl;
}

function addCard(info) {
    //花色
    let decor = info.card.decor;
    //类型
    let type = info.card.type;
    let divEl = document.createElement("div");
    // divEl.className = "pic";
    // if (info.level == 0) {
    //     divEl.style.backgroundPosition = (info.card.number - 1) * -80 + "px 0px";
    // } else {
    //     divEl.style.backgroundPosition = "0px 720px";
    // }

    // //后续需根据花色和类型来选择雪碧图中的图片
    // divEl.style.left = array[info.index][0] + 'px';
    // divEl.style.top = array[info.index][1] + 'px';
    // divEl.style.zIndex = levelSize + 1 - info.level;
    //自定义属性，设定一些数值
    divEl.setAttribute("type", info.card.type);
    divEl.setAttribute("color", info.card.color);
    divEl.setAttribute("decor", info.card.decor);
    divEl.setAttribute("number", info.card.number);
    divEl.setAttribute("index", info.index);
    return divEl;
}
export {
    addBottomCard,
    addCard,
    addTableCard
}